package com.xgggh.redpack;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.app.Activity;
import android.widget.Toast;

import com.jakewharton.rxbinding2.view.RxView;
import com.xgggh.app.RxBaseActivity;
import com.xgggh.redpack.databinding.ActivityRedPackBinding;

import java.util.concurrent.TimeUnit;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;

/**
 * @Title  发红包
 */
public class RedPackActivity extends RxBaseActivity {

    ActivityRedPackBinding mBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding= DataBindingUtil.setContentView(this,R.layout.activity_red_pack);
        setSupportActionBar(mBinding.toolBarParent.toolbar);

        RxView.clicks(mBinding.contentRedPack.send)
                .throttleFirst(windowDuration, TimeUnit.SECONDS)
                .subscribeOn(AndroidSchedulers.mainThread())
                .compose(bindToLifecycle())
                .subscribe(new Consumer<Object>() {
                    @Override
                    public void accept(Object o) throws Exception {
                        Toast.makeText(RedPackActivity.this, "发布成功", Toast.LENGTH_SHORT).show();
                        setResult(RESULT_OK,getIntent());
                        finish();
                    }
                });

    }

}
